 
<!--
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 14:41:20
 * @LastEditTime: 2023-08-31 09:43:44
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description:   :gridOps="gridOptions" allocation
-->
<template>
  <el-dialog  draggable overflow  :title="'小样配方'" :width="1000" destroy-on-close @closed="emit('closed')">
    <el-row>
      <el-col :span="11" style="border-right: 1px solid #ccc;border-top: 1px solid #ccc;">
        <sc-VxeTable ref="xGrid" :tablecode="'pro_color_rev_browser'" :gridOps="{ height: 600 }"
          :url="api.pro.color.details" :gridEvts="gridEvents" :params="props.params">
        </sc-VxeTable>
      </el-col>
      <el-col :span="13" style="border-right: 1px solid #ccc;border-top: 1px solid #ccc;">
        <sc-VxeTable :tablecode="'pro_color_rev_view_list'" :gridOps="{ height: 600 }" :data="selectItems">
        </sc-VxeTable>
      </el-col>
    </el-row>
    <fauditDialog v-if="dialog.faudit" ref="reffaudit" @success="handleSuccess" @closed="dialog.faudit = false">
    </fauditDialog>
  </el-dialog>
</template>
<script>
export default {
  name: "pro_color_details",
};
</script>
<script setup>
import { ref, nextTick } from "vue";
import fauditDialog from "./faudit";
import { ElNotification } from "element-plus";
import api from "@/api";

const props = defineProps({
  params: Object,

});
const emit = defineEmits(["select", "closed"]);
const reffaudit = ref({});
const xGrid = ref({});
const selectItems = ref([]);
const dialog = ref({
  faudit: false,
});

const handleSuccess = () => {
  xGrid.value.refresh();
};
const selectEvt = (data) => {
  if (data.status_id != 2) {
    return ElNotification.error({ title: "无法选择", message: "没有终审！必须终审核才可以使用！" });
  }
  emit("select", data, selectItems.value);
}
const gridEvents = {
  cellDblclick: ({ row }) => selectEvt(row),
  choose: ({ button }) => selectEvt(button.selectRecords[0]),
  faudit: function (data) {
    dialog.value.faudit = true;
    if (typeof data.$grid !== "undefined") {
      data = data.$grid.getCheckboxRecords()[0];
    }
    nextTick(() => {
      reffaudit.value.setData(data);
      reffaudit.value.open();
    });
  },
  selectData(selectRecords) {
    selectItems.value = selectRecords[0].items;
  }
};
</script>
